package com.mobilelmes.test;

import android.test.ActivityInstrumentationTestCase2;
import android.test.TouchUtils;
import android.widget.Button;
import android.widget.EditText;

import com.robotium.solo.Solo;
import com.mobilelmes.Main;

public class testMain extends ActivityInstrumentationTestCase2<Main> {
	private Main mActivity;
	//EditText edtID, edtPW;
	EditText etNewTask;
	Button annoButton, calendarButton, todolistButton;
	private Solo solo;

	public testMain() {
		super(Main.class);
		// TODO Auto-generated constructor stub
	}

	protected void setUp() throws Exception {
		// this method is called every time before any test execution
		super.setUp();
		solo = new Solo(getInstrumentation(), getActivity());
		mActivity = (Main) getActivity(); // get current activity
		// link the objects with the activity objects
		//annoButton = (Button) solo.getCurrentActivity().findViewById(com.mobilelmes.R.id.annoButton);
		//calendarButton = (Button) solo.getCurrentActivity().findViewById(com.mobilelmes.R.id.calendarButton);
		//todolistButton = (Button) mActivity.findViewById(com.mobilelmes.R.id.todolistButton);
		etNewTask = (EditText) mActivity.findViewById(com.mobilelmes.R.id.etNewTask);
		//edtPW = (EditText) mActivity.findViewById(com.mobilelmes.R.id.edtPW);

	}

	@Override
	protected void tearDown() throws Exception {
		// TODO Auto-generated method stub
		//edtID.clearComposingText();
		//edtPW.clearComposingText();
		//etNewTask.clearComposingText();
		super.tearDown();
		//solo.finishOpenedActivities();
	}

	public void testView() { // checks if the activity is created
		assertNotNull(getActivity());

	}
	
	public void testChangeToSchedule() {
		solo.waitForActivity("Main");
		solo.clickOnImageButton(1);
		//solo.sleep(3000);
		//solo.enterText(etNewTask,"1234");
		//solo.sleep(100000);
		boolean yyy = solo.searchText("Lang");;
		assertTrue("Testing for chande to schedule", yyy);
	}
	
	public void testChangeToAn() {
		solo.waitForActivity("Main");
		solo.clickOnImageButton(1);
		solo.clickOnImageButton(0);
		//solo.sleep(3000);
		//solo.enterText(etNewTask,"1234");
		//solo.sleep(100000);
		boolean yyy = solo.searchText("COMP3111");;
		assertTrue("Testing for chande to an", yyy);
	}
	
	public void testChangeToAnfirst() {
		solo.waitForActivity("Main");
		solo.clickOnImageButton(1);
		solo.clickOnImageButton(0);
		//solo.sleep(3000);
		//solo.enterText(etNewTask,"1234");
		//solo.sleep(100000);
		solo.clickInList(0, 0);
		boolean yyy = solo.searchText("Pop");;
		assertTrue("Testing for chande to an", yyy);
	}
	
	public void testChangeToAnfirstclose() {
		solo.waitForActivity("Main");
		solo.clickOnImageButton(1);
		solo.clickOnImageButton(0);
		//solo.sleep(3000);
		//solo.enterText(etNewTask,"1234");
		//solo.sleep(100000);
		solo.clickInList(0, 0);
		solo.clickInList(0, 0);
		boolean yyy = !solo.searchText("Pop");;
		assertTrue("Testing for chande to an", yyy);
	}
	
	public void testChangeToAnsecnd() {
		solo.waitForActivity("Main");
		solo.clickOnImageButton(1);
		solo.clickOnImageButton(0);
		//solo.sleep(3000);
		//solo.enterText(etNewTask,"1234");
		//solo.sleep(100000);
		solo.clickInList(0, 1);
		boolean yyy = solo.searchText("Self-Test 2");;
		assertTrue("Testing for chande to an", yyy);
	}
	
	/*public void testChangeToAnsecndclose() {
		solo.waitForActivity("Main");
		solo.clickOnImageButton(1);
		solo.clickOnImageButton(0);
		//solo.sleep(3000);
		//solo.enterText(etNewTask,"1234");
		//solo.sleep(100000);
		solo.clickInList(0, 1);
		solo.clickInList(0, 1);
		boolean yyy = !solo.searchText("Self-Test 2");;
		assertTrue("Testing for chande to an", yyy);
	}*/
	
	/*public void testChangeToTodo() {
		solo.waitForActivity("Main");
		solo.clickOnImageButton(2);
		//solo.sleep(3000);
		//solo.enterText(etNewTask,"1234");
		//solo.sleep(100000);
		sendKeys("1");
		boolean yyy = solo.searchText("1");;
		assertTrue("Testing for chande to Todo", yyy);
	}*/

	
}